<template>
    <pageTabelLayout>
        <template #pageHeader>

            <div class="search-form divClass" v-if="headerShow">
                <div>
                    <a-form :model="pageData" layout="inline" size="small">
                        <a-form-item label="车间" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" disabled v-model="pageData.workshop" allow-clear></a-input>
                        </a-form-item>
                        <a-form-item label="当班日期" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-date-picker  popup-container="html"  class="bacClass" v-model="pageData.beginDate" allow-clear />
                        </a-form-item>
                        <a-form-item label="至" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-date-picker  popup-container="html"  class="bacClass" v-model="pageData.endDate" allow-clear />
                        </a-form-item>
                        <a-form-item label="班次" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-select popup-container="html"  class="bacClass" :allowClear="true" v-model="pageData.workteam" :filter-option="false"
                                allow-search>
                                <a-option>A班</a-option>
                                <a-option>B班</a-option>
                            </a-select>
                        </a-form-item>
                        <!-- <a-form-item label="班组">
                            <a-input class="bacClass" v-model="pageData.workteam" allow-clear
                                ></a-input>
                        </a-form-item> -->
                        <a-form-item label="配方单号" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" v-model="pageData.formulaCode" allow-clear></a-input>
                        </a-form-item>
                        <a-form-item label="流转卡号" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" v-model="pageData.circulatCard" allow-clear></a-input>
                        </a-form-item>
                        <a-form-item label="品名" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" disabled v-model="pageData.brandName" allow-clear></a-input>
                        </a-form-item>
                        <a-form-item label="色号" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" disabled v-model="pageData.colorCode" allow-clear></a-input>
                        </a-form-item>
                        <a-form-item label="色称" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" disabled v-model="pageData.colorName" allow-clear></a-input>
                        </a-form-item>
                        <a-form-item label="设备编号" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" disabled v-model="pageData.machineCode" allow-clear></a-input>
                        </a-form-item>
                        <a-form-item label="员工工号" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" v-model="pageData.userCode" allow-clear></a-input>
                        </a-form-item>
                        <a-form-item label="员工姓名" :style="{ width: '270px' }" label-col-flex="70px">
                            <a-input class="bacClass" disabled v-model="pageData.userName" allow-clear></a-input>
                        </a-form-item>
                    </a-form>
                </div>

            </div>
            <div style="float: right;">
                <Toolbar :items="toolbarList" @select="selectHandler">
                </Toolbar>
            </div>
            <div class="my-divisders">
                <a-divider orientation="center">
                    <icon-double-up v-if="headerShow" @click="headerShow = false" :strokeWidth="2" :size="18" />
                    <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
                </a-divider>
            </div>
        </template>
        <template #pageTabel>
            <!-- <a-tabs   :justify="true" :default-active-key="tabsKeys" @change="tabsChanges">
                <a-tab-pane> -->
            <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady"
            style="height: calc(100% - 45px);" :defaultColDef="defaultColDef" class='ag-theme-alpine' :rowData="tableDataList"
                :columnDefs="tc" :localeText="localeText1"></AgGridVuesCopys>
            <paginationCopys :page-size-options="pagingList1" :total="total" show-total show-jumper show-page-size
                @change="PageSize" @page-size-change="change" style="justify-content: center"
                :page-size="pagination.pageSize" :current="pagination.page" />
            <!-- </a-tab-pane>
            </a-tabs> -->
        </template>

    </pageTabelLayout>
</template>
<script setup lang="ts">
import {
    useTable,
    useRowKey,
    useTableColumn,
    usePagination,
    useRowSelection,
} from "@/hooks/table";
import { ref, reactive } from "vue"
import { post, get } from "@/api/http"
import { localeText } from '@/api/aggridZw'

import Toolbar from "@/components/Toolbar.vue"
import { Message, Modal } from "@arco-design/web-vue"
import CorporateSectorCascader from '@/components/corporateSectorCascader/inde.vue'
import { FormInstance } from "@arco-design/web-vue/es/form";
import { pagingList } from "@/api/paging";
import { baseURL } from '../../../../api/axios.config'
import axios from "axios";
const toolbarList: any = ref(['查询'])

function PageSize(val: any) {
    pagination.page = val
    doRefresh();
}

function change(val: any) {
    pagination.pageSize = val
    doRefresh();
}
const headerShow = ref(true)
const tableDataList = ref([])


const gridOption = ref()
const gridReady = (params: any) => {
    gridOption.value = params.api
}
const defaultColDef = {
    sortable: true,
    resizable: true,
    filter: true,
}
const localeText1: any = ref(localeText)
const tc = [
    {
        showRowGroup: 'hide_def',
        "headerName": "",
        "checkboxSelection": true,
        "headerCheckboxSelection": true,
        "pinned": "left",
        "width": 50,
        resizable: false,
        filter: false,
        sortable: false,
        minWidth: 50,
        maxWidth: 50,
        lockPosition: "left",
    },
    {
        headerName: '车间',
        field: 'workshop',
        width: 150,
        filter: 'workshop',
    },
    {
        headerName: '配方单号',
        field: 'formulaCode',
        width: 150
    },
    {
        headerName: '计件日期',
        field: 'workDate',
        width: 150
    },
    {
        headerName: '流转卡号',
        field: 'circulatCard',
        width: 150
    },
    {
        headerName: '设备编号',
        field: 'machineCode',
        width: 150
    },
    {
        headerName: '班次',
        field: 'workteam',
        width: 150
    },
    // {
    //     headerName: '班组',
    //     field: 'workteam',
    //     width: 150
    // },
    {
        headerName: '员工工号',
        field: 'userCode',
        width: 150
    },
    {
        headerName: '员工姓名',
        field: 'userName',
        width: 150
    },
    {
        headerName: '总步骤数',
        field: 'stepTotalNum',
        width: 150
    },
    {
        headerName: '步骤数',
        field: 'stepNum',
        width: 150
    },
    {
        headerName: '单价',
        field: 'price',
        width: 150
    },
    {
        headerName: '客户名称',
        field: 'customName',
        width: 150
    },
    {
        headerName: '布号',
        field: 'clothCode',
        width: 150
    },
    {
        headerName: '品名',
        field: 'brandName',
        width: 150
    },
    {
        headerName: '色号',
        field: 'colorCode',
        width: 150
    },
    {
        headerName: '色称',
        field: 'colorName',
        width: 150
    },
    {
        headerName: '匹数',
        field: 'horseNum',
        width: 150
    },
    {
        headerName: '重量',
        field: 'weight',
        width: 150
    },

    {
        headerName: "创建人",
        field: "createName",
        width: 150
    },
    {
        headerName: "创建时间",
        field: "createTime",
        width: 150
    },
    {
        headerName: "最后修改人",
        field: "updateName",
        width: 150
    },
    {
        headerName: "最后修改时间",
        field: "updateTime",
        width: 150
    },

]

const pageData = reactive<{
    pageLoading: boolean,
    workshop: any,

    beginDate: any,
    endDate: any,
    shift: any,
    workteam: any,
    formulaCode: any,
    circulatCard: any,
    brandName: any,
    colorCode: any,
    colorName: any,
    machineCode: any,
    userCode: any,
    userName: any,
    deleteState: any,
    page: any,
    size: any,
}>({
    pageLoading: false,
    workshop: '',

    beginDate: '',
    endDate: '',
    shift: '',
    workteam: '',
    formulaCode: '',
    circulatCard: '',
    brandName: '',
    colorCode: '',
    colorName: '',
    machineCode: '',
    userCode: '',
    userName: '',
    deleteState: 0,
    page: null,
    size: null,
});
const selectHandler = () => {
    doRefresh()
}

// 查询事件
const total = ref(10);
const pagingList1: any = ref(pagingList)
function doRefresh() {
    pageData.pageLoading = true
    pageData.page = pagination.page,
        pageData.size = pagination.pageSize,
        post({
            url: "/dwPc/DyeFormulaYield/getPage",
            // data: {
            //     page: pagination.page,
            //     size: pagination.pageSize,
            //     deleteState: 0,
            // },
            data: pageData,
        })
            .then(({ data, code }: any) => {
                if (code === 200) {

                    table.handleSuccess(data.list);
                    gridOption.value.setRowData(data.list)
                    total.value = data.total;

                }
            })
            .catch(console.log).finally(() => {
                pageData.pageLoading = false
            })
}
const pagination = usePagination(doRefresh);
const table = useTable();
</script>
<script lang="ts">
export default {
    name: "DyeingFormulaScanningQuery",
}
</script>
<style scoped lang="less">
:deep(.ag-cell) {
    border-right: 1px solid #dde2eb;
}

:deep(.ag-header-cell) {
    border-right: 1px solid #dde2eb;
}

:deep(.ag-cell-value) {
    user-select: initial;
    -moz-user-select: text;
    -ms-user-select: text;
    -webkit-user-select: text;
}
</style>

